import Raw
import traceback


print("Add(10, 2) =", Raw.Add(10, 2))
print("Sub(10, 2) =", Raw.Sub(10, 2))
print("")

print("wxPAPER_NONE =", Raw.wxPAPER_NONE)
print("V_OUT =", Raw.V_OUT)
print("EnumClass::YES =", Raw.EnumClass.YES)
print("EnumClass::NO =", Raw.EnumClass.NO)
print("K::ES::VAL =", Raw.K.ES.VAL)
print("")

print("X.X2:", Raw.X.X2)
print("")

x = Raw.X(10)
try:
    x.Func123()
except AttributeError:
    traceback.print_exc()

ret = x.Func1()
print(" -- Got result from Func1():", ret)

x.Func1("Shadowed?")

x.Func2()
x.Func2(1000)
ret = x.Func2(2000.0)
print(" -- Got result from Func2():", ret)

ret = x.Func3(65535)
print(" -- Got result from Func3():", ret)

ret = x.Func4(255)
print(" -- Got result from Func4():", ret)

x.Injected()
print(x.Injected2())

Raw.X.Static(-1)

x999 = Raw.X("Hello wxn!")
print(x999.GetDouble())

print("")

inner2 = Raw.X.Inner.MostInner()
print(inner2)
print("wx.X.Inner.MostInner.MIN_FLAG:", Raw.X.Inner.MostInner.MIN_FLAG)

print("")

print(Raw.Drawable.MSW.Create(Raw.Drawable.BITMAP, False))
print("")

cl = Raw.MyColor()
print(cl.Red())
print(cl.Green())
print("")

#-------------------------------------------------------------------

class YY(Raw.Y):
    def Echo(self, *args, **kwargs):
        print("YY.Echo == From subtype in Python! (generic args)")
        print("args:", args)
        print("kwargs:", kwargs)

    def Func1(self):
        print("YY.Func1 == From subtype in Python! (no args)")
        return 19900905

yy = YY()
yy.DoEcho()
yy.ZZ()

int_ptr = yy.GetIntPtr()
print(int_ptr)
yy.SetIntPtr(int_ptr)

print("")

double_ref = yy.GetDoubleRef()
print(double_ref)
yy.SetDoubleRef(double_ref)

print("")

y1 = yy.GetY1()
print(yy)
print(y1)

y1.DoEcho()

print(yy.GetY2())
print(yy.GetY3())
print(yy.GetY4())
print(yy.GetY5())
print(yy.GetY6())
print(yy.SetY1(y1))

print("")

xval = yy.GetXInstance()
print(xval)

ret = xval.Func3(1990)
print(" -- Got result from Func3():", ret)

yy.SetXInstance(xval)

print("")

print(yy.DoFunc1())

print("")

class MyPrivatePureVirtual(Raw.PrivatePureVirtual):
    def PV(self):
        print("MyPrivatePureVirtual -- From subtype in Python! (no args)")

pv = MyPrivatePureVirtual()
pv.DoPV()

print("")

pm = Raw.ProtectedMembers()
pm.InvokeProtected()

print("")

print("class YY:")
print(dir(yy))

print("")

print(Raw.PrintY(yy))

print("")

yy.PrintZ()
print("z attribute:", yy.z)

yy.z += 10
print("z attribute:", yy.z)
print("z0 attribute:", yy.z0)

print("")

print(yy.x.GetDouble())
print(yy.px)

print("")

xxx = Raw.X(102.4)
yy.px = xxx
print(yy.px.GetDouble())

print("")

xxxx = Raw.X(2048)
yy.x = xxxx
print(yy.x.GetDouble())

#-------------------------------------------------------------------#

print("\n######### The following is intended to incur errors ##############")

try:
    Raw.EnumClass()
except SystemError:
    traceback.print_exc()
    print("\n\n")

class YYY(Raw.Y):
    def Echo(self, i):
        print("I want to return an int!!")

        return 1000000

    def PV(self, d):
        print(d)
        return -1000.1234

yyy = YYY()
yyy.DoPV(999999.99)
yyy.Func1("Call from a pythonic object...")
# yyy.DoEcho() -- C++ side will throw an exception

print("")

#-------------------------------------------------------------------

x = Raw.X()

try:
    ret = x.Func2("")
except TypeError:
    traceback.print_exc()
    print("\n\n")

try:
    x = Raw.X("")
except:
    traceback.print_exc()

print("")

try:
    y = Raw.Y()
except SystemError:
    traceback.print_exc()

print("")
print("")

#-------------------------------------------------------------------

z = Raw.Z(2037)

print(Raw.F1(11, 12, 13))
print("")

Raw.F2(None)
Raw.F2(None, p=None, z=z)
Raw.F2(None, None, z, Raw.Z(2020))
print("")

Raw.F3()
Raw.F3(False, z)
Raw.F3(True)
print("")

Raw.F4()
Raw.F4("Why not use Python?")
print("")

print("")
print("")

#-------------------------------------------------------------------

print(Raw._z)
print(Raw._pz.GetValue())
print(Raw.PI)
print(Raw.wxToolBarNameStr)
print(Raw.EmptyString)

print("")

#-------------------------------------------------------------------

assert not hasattr(Raw, "MyVar")
print(Raw.MyVarInt)
print(dir(Raw.MyVarInt))
print(Raw.MyVarInt.value)

ti = Raw.T_Class_int()
ti.m = 1024 * 1024
print(Raw.Why(ti))
print("")

Raw.TestVector()
Raw.TestVector([1, 2, 3, 4,])
try:
    Raw.TestVector([1, 2, 3, 4, "123"])
except TypeError:
    traceback.print_exc()

print("")

lst = [6, 7, 8, 9,]
Raw.TestVector2(lst)
print(lst)
print("")

lst = [1.1, 2.2,]
Raw.TestVector3(lst)
print(lst)
print("")

lst = [3.3, 5.5,]
Raw.TestVector4(lst)
print(lst)
print("")

Raw.TestVector4(None)
print("")
print("")


d = {"A": 65, "B": 66,}
Raw.TestDict(d)
print(d)
print("")

print(Raw._vi)

Raw._vi.append(201410181652)
print(Raw._vi)
print("")

print(Raw._d)

del Raw._d["age"]
print(Raw._d)

print("")
print("")

#-------------------------------------------------------------------

print(Raw.TestPyObject(101))
print("")
print("")

#-------------------------------------------------------------------

pcd = Raw.PrivateCDtors.GetInstance()
print(pcd)
print("")
print("")

#-------------------------------------------------------------------

cxxh = Raw.CXXHeld()
holder1 = Raw.ObjHolder(cxxh)
holder1.foo()
del cxxh
holder1.foo()  # cxxh should still exist
print("")
print("")

class PyCXXHeld2(Raw.CXXHeld2):
    def __init__(self):
        Raw.CXXHeld2.__init__(self)

    def foo(self):
        print("PyCXXHeld2.foo()")

cxxh2 = PyCXXHeld2()
holder2 = Raw.ObjHolder(cxxh2)
holder2.foo()  # PyCXXHeld2.foo() should be called
del cxxh2
holder2.foo()  # PyCXXHeld2.foo() should be called
print("")
print("")
